package com.bf.electroplating.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.WasteWaterTypeVO;
import com.bf.electroplating.pojo.vo.sewageWarningConfig.SewageWarningDTO;
import com.bf.electroplating.pojo.vo.sewageWarningConfig.SewageWarningQueryDTO;
import com.bf.electroplating.pojo.vo.sewageWarningConfig.SewageWarningVO;
import com.bf.electroplating.service.ISewageWarningConfigService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 污水预警管理表 前端控制器
 * </p>
 *
 * @author gzd
 * @since 2025-08-21
 */
@Tag(name = "污水警告")
@RestController
@RequestMapping("/electroplating/sewageWarningConfig")
public class SewageWarningConfigController {
    @Resource
    private ISewageWarningConfigService contingencyPlanService;

    @PostMapping( "/pageList" )
    @Operation( summary = "分页查询污水预警管理列表", description = "分页查询污水预警管理列表" )
    public ResultVO <Page<SewageWarningVO>> pageList (@RequestBody SewageWarningQueryDTO queryDTO ) {
        return contingencyPlanService.pageList ( queryDTO );
    }

    @Idempotent
    @PostMapping ( "/saveData" )
    @Operation ( summary = "新增/编辑污水预警管理", description = "新增/编辑污水预警管理" )
    public ResultVO< String > saveData (@RequestBody @Validated SewageWarningDTO dto ) {
        return contingencyPlanService.saveData ( dto );
    }

    @PostMapping ( "/delete" )
    @Operation ( summary = "删除污水预警管理", description = "删除污水预警管理" )
    public ResultVO < String > delete ( @RequestBody List< String > ids ) {
        return contingencyPlanService.delete ( ids );
    }

    @PostMapping ( "/detail" )
    @Operation ( summary = "获取污水预警管理详情", description = "获取污水预警管理详情" )
    public ResultVO < SewageWarningVO > getDetail ( @RequestBody IdDTO idDTO ) {
        return contingencyPlanService.getDetail ( idDTO.getId () );
    }


    @GetMapping ( "/getWasteWaterTypeByCompanyId" )
    @Operation ( summary = "基于企业获取污水类型", description = "基于企业获取污水类型" )
    public ResultVO <List<WasteWaterTypeVO>> getWasteWaterTypeByCompanyId (@RequestParam("companyId") String companyId ) {
        return contingencyPlanService.getWasteWaterTypeByCompanyId ( companyId );
    }


    @GetMapping ( "/getListByCompanyAndWasterType" )
    @Operation ( summary = "基于企业污水类型获取后续", description = "基于企业污水类型获取后续" )
    public ResultVO <List<SewageWarningVO>> getListByCompanyAndWasterType (@RequestParam("companyId") String companyId
            ,@RequestParam("wasterType")   String wasterType) {
        return contingencyPlanService.getListByCompanyAndWasterType ( companyId,wasterType );
    }
}
